#pragma once

#include <cppunit/config/SourcePrefix.h>
#include "TestSynTable.h"
#include "Synonym.h"
#include "SynTableEntry.h"
#include <string>

using namespace std;

void TestSynTable::setUp()
{
}

void TestSynTable::tearDown() 
{
}

void TestSynTable::testAddSyn() 
{
	SynTable mySynTable;
	Synonym *testSynonym = new Synonym(Q_ASSIGN, "a");
	Synonym *testSynA = new Synonym(Q_ASSIGN, "a");

	vector<int> testValuesA;
	testValuesA.push_back(1);

	Synonym *testSynonym2 = new Synonym(Q_STATEMENT, "s1");
	Synonym *testSynB = new Synonym(Q_STATEMENT, "s1");

	vector<int> testValuesB;
	testValuesB.push_back(1);
	testValuesB.push_back(1);
	testValuesB.push_back(10);

	SynTableEntry testEntry(testSynA, 0);
	testEntry.addValues(testValuesA);
	SynTableEntry testEntry2(testSynB, 1);
	testEntry2.addValues(testValuesB);

	//test adding new Synonyms into the table
	mySynTable.addSyn(testSynonym, testValuesA);
	CPPUNIT_ASSERT_EQUAL(mySynTable.getNoOfEntries(), 1);
	mySynTable.addSyn(testSynonym2, testValuesB);
	CPPUNIT_ASSERT_EQUAL(mySynTable.getNoOfEntries(), 2);

	SynTableEntry temp = mySynTable.getAt(0);
	CPPUNIT_ASSERT_EQUAL(temp.getEntryNo(), testEntry.getEntryNo());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().size(), testEntry.getValues().size());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(0), testEntry.getValues().at(0));
	temp = mySynTable.getByName("a");
	CPPUNIT_ASSERT_EQUAL(temp.getEntryNo(), testEntry.getEntryNo());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().size(), testEntry.getValues().size());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(0), testEntry.getValues().at(0));

	temp = mySynTable.getAt(1);
	CPPUNIT_ASSERT_EQUAL(temp.getEntryNo(), testEntry2.getEntryNo());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().size(), testEntry2.getValues().size());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(0), testEntry2.getValues().at(0));
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(1), testEntry2.getValues().at(1));
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(2), testEntry2.getValues().at(2));
	temp = mySynTable.getByName("s1");
	CPPUNIT_ASSERT_EQUAL(temp.getEntryNo(), testEntry2.getEntryNo());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().size(), testEntry2.getValues().size());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(0), testEntry2.getValues().at(0));
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(1), testEntry2.getValues().at(1));
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(2), testEntry2.getValues().at(2));

	//test adding duplicate Synonyms into the table
	mySynTable.addSyn(testSynonym2, testValuesA);
	CPPUNIT_ASSERT_EQUAL(mySynTable.getNoOfEntries(), 2);
	testEntry2.checkValues(testValuesA);
	temp = mySynTable.getAt(1);
	CPPUNIT_ASSERT_EQUAL(temp.getEntryNo(), testEntry2.getEntryNo());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().size(), testEntry2.getValues().size());
	CPPUNIT_ASSERT_EQUAL(temp.getValues().at(0), testEntry2.getValues().at(0));
}

void TestSynTable::testGetResults() 
{
}